package com.atguigu.pratice;

import java.util.concurrent.atomic.AtomicInteger;

//盲打练习之 CAS
public class CASDemoPriatice {
    //v1 多线程环境下不使用原子类AtomicInteger保证线程安全
    private int number =0;
    public int getNumber(){
        return number;
    }
    public synchronized void setNumber(){
        number++;
    }
    //v2  多线程环境下使用原子类AtomicInteger保证线程安全
    AtomicInteger atomicInteger = new AtomicInteger(0);

}
